namespace Entity
{
    using Component;
    public abstract class Entity(int id)
    {
        public int Id { get; } = id;
    }
    public class Hierarchies<T>
    {
        private List<Entity?> entities = [];
        private List<T?> components = [];
        public void AddPair(Entity entity, T component)
        {
            if (entity.Id > entities.Count)
            {
                // 若超过了List上限，则先扩容再插入
                entities.AddRange(Enumerable.Repeat<Entity?>(default, entity.Id - entities.Count));
                components.AddRange(Enumerable.Repeat<T?>(default, entity.Id - components.Count));
                entities.Add(entity);
                components.Add(component);
            }
        }
    }
}